﻿using System.Drawing;

namespace Common.Core.ImageHelper
{
    public static class ImageLoader
    {
        /// <summary>
        /// 使用非独占的方式读取图片
        /// </summary>
        /// <param name="filePath"></param>
        /// <returns></returns>
        public static Image Fun1(string filePath)
        {
            if (!File.Exists(filePath)) return null;

            Stream s = File.Open(filePath, FileMode.Open);

            var img= Image.FromStream(s);

            s.Close();

            return img;
        }

        public static Stream Fun2(string filePath)
        {
            if (!File.Exists(filePath)) return null;

            Stream s = File.Open(filePath, FileMode.Open,FileAccess.Read);

            Stream s1 = new MemoryStream();

            s.CopyTo(s1);

            s.Close();

            return s1;
        }
    } 
}
